package com.hghivln.erpwarehouse.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * <p>
 * 菜单管理实体
 * </p>
 *
 * @author hghivln
 * @since 2021-06-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_menu")
@AllArgsConstructor
@NoArgsConstructor
public class Menu implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 父级菜单ID
     */
    private Integer pid;

    /**
     * 类型[topmenu/leftmenu/permission]
     */
    private String type;

    /**
     * 名称
     */
    private String title;

    /**
     * topmenu:system/business
     */
    private String typecode;

    /**
     * 图标
     */
    private String icon;

    /**
     * 连接地址
     */
    private String href;

    /**
     * _self的话 是指在本身这个网页窗口来打开新的网页链接
     */
    private String target;

    private Integer spread;

    @TableField(exist = false)
    private Boolean open;

    private Integer ordernum;

    /**
     * 状态【0不可用1可用】
     */
    private Integer available;


    public Boolean getOpen() {
        return this.spread.equals(1);
    }

    public Menu(Integer id, Integer pid, String type, String typecode, String title, String icon, String href, Integer ordernum, Integer available) {
        this.id = id;
        this.pid = pid;
        this.type = type;
        this.title = title;
        this.typecode = typecode;
        this.icon = icon;
        this.href = href;
        this.ordernum = ordernum;
        this.available = available;
    }

    public Menu(Integer id, Integer pid, String type, String typecode, String title, String href, Integer ordernum, Integer available) {
        this.id = id;
        this.pid = pid;
        this.type = type;
        this.title = title;
        this.typecode = typecode;
        this.href = href;
        this.ordernum = ordernum;
        this.available = available;
    }
}
